<?php
set_include_path ( get_include_path () . PATH_SEPARATOR . '../' );
include_once 'Include.php';

$userTable = new UserTable();
$id = req ('id');
$validate = req("validate");

$count = 0;
if($id != "" && $validate != ""){
	$d = $userTable->validate($id, $validate)->toArray();
	//echo "<pre>". print_r ($d, true) ."</pre>";

	$count = count($d);
	if($count > 0){ // ok
		$username= $d[0]["username"];
		
		//update state
		$where = $db->quoteInto ( 'id = ?', $id );
		$set = array ('state' => 1);
		$rows_affected = $userTable->update ( $set, $where );
		
		$href = WWW."web/sign_activate.php?id=".$id."&validate=".$validate;
		
		// send email
		$to      = $d[0]["email"];
		$subject = 'Welcome to aba4hire';			
		$headers = 'From: danny@simplebyte.net' . "\r\n" .
			'Reply-To: danny@simplebyte.net' . "\r\n" .
			'X-Mailer: PHP/' . phpversion();
		$message = "<p>Hi <<".$d[0]["username"].">>,</p>" . 
				"<p>Your account is now created.</p>".
				"<p>Your username is <<".$d[0]["username"].">>. You will need this to log in to your profile.</p>".
				"<p>To login use this link http://aba4hire.com. We recommend you bookmark the link</p>" .
				"<p>To get the most out of your membership we suggest you :</p>".
				"<p>1. Upload your picture</p>".
				"<p>2. this and that and that</p>".
				"<p>Thanks,aba4hire team</p>".
				"<hr />".
				"<p>We love to hear from you. Send us comments / opinions to support@aba4hire.com </p>" ;
				
		
		$send = @mail($to, $subject, $message, $headers);		
	}
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sign activate</title>
</head>

<body>

<?php
if($count != 0){
?>
<h3>Thanks for activating your account.</h3>
<p>Before you start we would like to share a few secrets with you.</p><br />
<pre>
Your registered username is <b><?=$username?></b>. You will need this to log in.
This is another task example you could do... <a href="#">link to your profile</a>.
<a href="#">some links links.</a>
</pre>
<?php
}else{
?>
<h3>Hey stranger, did you receive our activation email ?</h3>

<pre>
It seems your account is still unverified. To verify your account, you need to click on the
activation link we sent you to <<youremailaddress>>.
You didn't receive the activation email :
1. You used <<youremailaddress>> to sign up. Is this your valid email address ?
2. Did you check your spam / junk folder ?
3. Are you sure ? The email subject is "aba4hire.com Membership Activation".
</pre>
<p>Still can't find your email, click here to <a href="sign_sendemail.php?id=<?=$id?>">receive activation email again</a>.</p>
<pre>
If the above steps don't solve your problem please write an email to
support@aba4hire.com explaining your problem. We will get back to you.
</pre>



<?php
}	
?>

</body>
</html>
